<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class FootController extends Controller
{
    public function getIndex(){

        // var_dump(session('home_userid'));
        //关联查询用户浏览过的商品信息
        //今日内的足迹
        $res2=DB::table("tbl_foot")
        ->join("tbl_home_user","tbl_foot.uid","=","tbl_home_user.id")
        ->join("tbl_goods","tbl_foot.gid","=","tbl_goods.id")
        ->where("tbl_foot.uid","=",session("home_userid"))
        ->where('foottime','>',time()-24*3600)
        ->get();
        // dd($res2);
        // 一周内的足迹
        $res3=DB::table("tbl_foot")
        ->join("tbl_home_user","tbl_foot.uid","=","tbl_home_user.id")
        ->join("tbl_goods","tbl_foot.gid","=","tbl_goods.id")
        ->where("tbl_foot.uid","=",session("home_userid"))
        ->where('foottime','>',time()-7*24*3600)
        ->get();
        return view('/home/foot/foot',['list'=>$res2,'list2'=>$res3]);
    }
    public function getAdd(){
        $gid = $_GET['gid'];
        $uid = session('home_userid');
        $foottime = time();
        DB::table('tbl_foot')->insert([
                'uid'=>$uid,
                'gid'=>$gid,
                'foottime'=>$foottime
            ]);
    }
}
